<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Netuser extends Model
{
    protected $table = 'dd_netuser';
    protected $primaryKey = 'id';
    public $timestamps = false;
    protected $guarded = array();
    /**
     * 添加用户
     * @param \Illuminate\Http\Request $request
     * @param type $uid
     * @param type $orderid
     * @return type
     */
    public static function addNetUser(\Illuminate\Http\Request $request, $uid, $orderid, $ptype) {
        $info = $request->all();
        $info['uid'] = $uid;
        $info['orderid'] = $orderid;
        $info['ptype'] = $ptype;
        $res = static::firstOrCreate($info);
        if ($res) {
            return [
                'status'    => 1,
                'info'      => '（开户/续费）成功'
            ];
        }
        return [
            'status'    => 0,
            'info'      => '（开户/续费）失败'
        ];
    }
    /**
	* 获取产品商品
	*/
	public function strProduct() {
		$order = Order::find($this->orderid);
        $product = Product::find($order->productid);
		return $product->name;
	}
}
